<%@include file="../_include.jsp" %>
<%@include file="../_insession.jsp" %>

<form id="form2" method="post" enctype="multipart/form-data" action="${base }/employees/upload-cv.action">
	<label>Seleccionar archivo</label><input type="file" name="file" id="file"/>
	<br/>
	<input type="submit" value="Upload"/>
</form>

<div>
	<img id="imageUploaded" alt="" src=""/>
</div>


<script type="text/javascript">

$('#form2').submit(function(event){
	event.preventDefault();
	
	var filename = $("#file").val();
	
	var oMyForm = new FormData();
	oMyForm.append("file", file.files[0]);
	
	var form = $(this);
	var url = form.attr('action');
	
	$.ajax({
	    url: url,
	    data: oMyForm,
	    dataType: 'text',
	    processData: false,
	    contentType: false,
	    type: 'POST',
	    success: function(data){
	    	var uploadedFile = $.parseJSON(data);
	    	$('#imageUploaded').attr('src',baseURL+URLSeparator+"static/images/uploads/"+uploadedFile.name);
	    }
	  });
});

</script>